<template>
    <view class="content">
        <text class="content-text">初始化中~嘿咻ヾﾉ≧∀≦)o...</text>
        <!-- 加载条 -->
        <w-loading :text="_i18n('common').loading" mask="true" click="false" ref="loading"></w-loading>
    </view>
</template>

<script>
const MyApp = getApp();
const globalData = MyApp.globalData;
export default {
    computed: {
        i18n() {
            return globalData.$t('index');
        },
        _i18n: {
            set() {
                return globalData.$t;
            },
            get() {
                return globalData.$t;
            }
        }
    },
    onShow() {
        let _this = this;
        MyApp.addEventListenerClipboard(_this, function(e) {
            if (e == 2) {
                _this.init();
            }
        });
    },
    onLoad() {},
    methods: {
        init() {
            let config = uni.getStorageSync('sys_config'), _this = this;
            if (config) {
                _this.gotoPage(config);
            } else {
                MyApp.showLoading(_this.$refs.loading);
                _this.$http.post('/videos/config/getConfig', {}).then(res => {
                    MyApp.closeLoading(_this.$refs.loading);
                    config = res.data;
                    config.show_ad = isNaN(parseInt(config.show_ad)) ? 0 : config.show_ad;
                    this.gotoPage(config);
                });
            }
        },
        gotoPage(config){
            // 是否显示开屏广告
            if (config.show_ad == 1) {
                // 广告页
                uni.reLaunch({
                    url: '/pages/guide/list'
                });
            } else {
                MyApp.goHome();
            }
        }
    }
};
</script>

<style>
    .content {
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        align-items: center;
        align-content: center;
        height: 100vh;
    }
    .content-text {
        font-size: 12px;
    }
</style>
